<template>
  <div>
    <div class="table-operator" v-if="stage !== '05010' && stage !== '05050'">
      <a-button :disabled="status == '9' || status == '2' || status == '3'"
                v-permission="['30010']"
                type="primary"
                @click="showConfirm">
        提交审核
      </a-button>
      <a-button :disabled="status !== '2'"
                v-permission="['30020']"
                @click="setApproveReason('9')">
        同意
      </a-button>
      <a-button :disabled="status !== '2'"
                v-permission="['30020']"
                style="margin-top: 10px"
                type="danger"
                @click="setApproveReason('1')">
        拒绝
      </a-button>
    </div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      class="table_header_blue"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="false"
      :loading="loading"
    >
      <span slot="actionName">
        <a-space v-if="stage !== '05010' && stage !== '05050'" v-permission="['30010']">
          <a-button size="small" @click="downLoadTemplete()" type="primary" icon="download">
            模板下载
          </a-button>
          <a-upload v-if="stage !== '05010' && stage !== '05050'"
                    :disabled="status == '9' || status == '2' || status == '3'"
                    v-permission="['30010']"
                    :data="fileData" name="files" :showUploadList="false" :multiple="false" :headers="tokenHeader"
                    :action="url.upLoad" @change="handleImportExcel"
                    accept=".docx, .doc, .xlsx, .xls, .pdf, .jpeg, .png">
          <a-button size="small"
                    type="primary"
                    icon="import">上传</a-button>
        </a-upload>
        </a-space>
        <span v-else>操作</span>
      </span>
      <span slot="action" slot-scope="text, record">
        <a @click="OnPerview(record)">预览</a>
        <a-divider type="vertical"/>
        <a @click="OnDownLoad(record)">下载</a>
      </span>
    </a-table>
    <SelectApprove ref='approver' :id='id' @submitData='handleSubmit'></SelectApprove>
    <SetReason ref='setReason' @approveReason='approveData'></SetReason>
    <TempleteDownload ref="templeteDownload" :type="tempType" :url="url.templateUrl" />
  </div>
</template>

<script>
  import {filePerviewMixin} from '@/mixins/filePerviewMixin'
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import SelectApprove from '../public/SelectApprover'
  import SetReason from "../public/SetReason"
  import columns from './indexColumns'
  import {butStatus} from "../public/butStatus";
  import TempleteDownload from '@views/sj/components/TempleteDownload.vue'

  export default {
    name: "bgxdb",
    mixins: [JeecgListMixin, filePerviewMixin, butStatus],
    components: {
      TempleteDownload,
      SelectApprove,
      SetReason
    },
    props: ['id', 'type', 'stage'],
    data() {
      return {
        queryParam: {
          id: this.id,
          typeId: this.type,
        },
        fileData: {
          biz: 'baogao_dg',
          type: 'baogao_dg',
          proId: this.id
        },
        typeId: '500', // 跟以前的报告定稿区分开
        bgType: 'baogao_dg',
        statusKey: 'dg',
        //表头
        importExcelUrl: `${window._CONFIG['domianURL']}/test/jeecgDemo/importExcel`,
        columns: columns(this),
        url: {
          list: '/sjxmzygl/sjWorkBaogao/queryAuditReportInfo',
          submit: '/sjxmzygl/sjWorkUsers/submitAudit',
          approve: '/sjxmzygl/sjWorkUsers/zyApplyCommit',
          saveBg: '/sjxmzygl/sjWorkBaogao/saveBg',
          upLoad: `${window._CONFIG['domianURL']}/sys/common/sjBgUpload`,
          templateUrl: '/xtsz/sjWordTemplate/list',
        },
        tempType: 'baogao_dg',
      }
    },
    created() {

    },
    methods: {}
  }
</script>

<style lang="less" scoped>
@import '~@assets/less/tableTheme.less';
</style>